import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-03-29
 * Time: 18:07
 */
public class Training_0327 {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
        int ret = maxLength (str1, str2);
        System.out.println(ret);
    }

    /**
     *
     * @param s1 字符串1
     * @param s2 字符串2
     * @return 返回最大的公告字符串长度
     */
    private static int maxLength(String s1, String s2) {
        int len1 = s1.length();
        int len2 = s2.length();
        int max = 0;
        int[][] f = new int[len1+1][len2+1];
        for(int i = 0; i <= len1; i++) {
            for(int j = 0; j <= len2; j++) {
                f[i][j] = 0;
            }
        }

        for(int i = 1; i <= len1; i++) {
            for(int j = 1; j <= len2; j++) {
                if(s1.charAt(i-1) == s2.charAt(j-1)) {
                    f[i][j] = f[i-1][j-1] + 1;
                } else {
                    f[i][j] = 0;
                }
            }
        }
        for(int i = 0; i <= len1; i++) {
            for(int j = 0; j<=len2; j++) {
                if(f[i][j] > max) {
                    max = f[i][j];
                }
            }
        }

        return max;
    }


    /**
     *
     * @param args 字符串翻转 abcd -> dcba
     */
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        int end = str1.length() - 1;
        int start = 0;
        char[] arr = str1.toCharArray();
        while(start < end) {
            char temp = 0;
            temp = arr[end];
            arr[end] = arr[start];
            arr[start] = temp;
            start++;
            end--;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
